<?php
if (isset($_POST['descrip'])) {


    $dom = new DomDocument();
    $dom->load('commentaires.xml');
    $root = $dom->documentElement;
    $commentaire = $dom->createElement("commentaire");

    $xpath = new DOMXPath($dom);
    $numCommentValue = $xpath->query('count(//commentaire[idFilm=' . $_POST['idFilm'] . '])');
    $numComment = $dom->createElement("numComment", $numCommentValue->length);

    $idFilm = $dom->createElement("idFilm", $_POST["idFilm"]);
    $codeClient = $dom->createElement("codeClient", $_POST["codeClient"]);
    $comment = $dom->createElement("comment", $_POST['descrip']);


    $commentaire->appendChild($idFilm);
    $commentaire->appendChild($numComment);
    $commentaire->appendChild($codeClient);
    $commentaire->appendChild($comment);

    $root->appendChild($commentaire);
    $dom->save('commentaires.xml');


    /* print ("<script language = \"JavaScript\">"); 
      print ("location.href = '../index.php?pagefilm=1.php';");
      print ("</script>");
     */
}
?>
<head>
    <title>Vidéo club -- La passion du cinéma</title>
    <meta name="Description" content="Projet Programmation Web 2012" />
    <meta name="Keywords" content="Projet Programmation Web 2012" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="alloinfo.js"></script>
    <link rel="stylesheet" type="text/css" href="../style.css" />
</head>





<!---------------------------------------------BODY--------------------------------------------->
<body>
    <div id="site">
        <div id="header">


            <div id="top">
                <div id="name_part_1" >La <span class="orange">P</span>assion</div>
                <div id="name_part_2" >du <span class="green">C</span>inema</div>	
            </div> <!-- Fin top -->




            <div id="main">	

                <?php echo "Nom du film : " . $_GET["nameFilm"]; ?>

                </br></br>
                </br>
                <form action="<?= $_SERVER['PHP_SELF']; ?>" method="post">
                    <textarea name="descrip" cols="50" rows="7" value="'.$descrip.'"> </textarea> 
                    </br>
                    <input type="submit" name="submit" value="Enregistrer">
                    <input type="hidden" name="idFilm" value="<?php echo $_GET['idFilm']; ?>" />
                    <input type="hidden" name="codeClient" value="<?php echo $_GET['codeClient']; ?>" />

                </form>

            </div> <!-- Fin main -->
        </div> <!-- Fin site -->		
</body> <!-- Fin body -->
</html> <!-- Fin html -->



